Imports Microsoft.VisualBasic

<Serializable()> _
Public Class Lookup
    Implements IComparable  'IMPORTANT


    Public season As Integer
    Public week As Integer
    Public id As Integer

    Public Sub Lookup(ByVal _s As Integer, ByVal _w As Integer, ByVal _i As Integer)
        season = _s
        week = _w
        id = _i

    End Sub

    Public Overrides Function ToString() As String

        Return season & "-" & week & "-" & id
    End Function

    Public Function CompareTo(ByVal obj As Object) As Integer Implements System.IComparable.CompareTo

        'where the Sorting logic is run

        'Basically says: "if ME greater than the obj card then return 1, if equal return 0 and if less than, return -1"

        If Not TypeOf obj Is Lookup Then Throw New ArgumentException 'make sure obj is a card before continuing

        Dim temp As Lookup = CType(obj, Lookup)
        Dim season As Integer = temp.season 'vObj
        Dim week As Integer = temp.week   'vMe
        Dim id As Integer = temp.id 's



        If Me.season < season Then
            Return -1
        ElseIf Me.season > season Then
            Return 1

        Else 'seasons are the same

            If Me.week < week Then
                Return -1
            ElseIf Me.week > week Then
                Return 1

            Else 'week are the same

                If Me.id < id Then
                    Return -1
                ElseIf Me.id > id Then
                    Return 1

                Else 'ids are the same
                    Return 0

                End If

            End If
        End If

    End Function


End Class
